<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="会员昵称" prop="nickname">
        <el-input
          v-model="queryParams.nickname"
          placeholder="请输入会员昵称"
          clearable
        />
      </el-form-item>
      <el-form-item label="订单号" prop="appointmentUser">
        <el-input
          v-model="queryParams.appointmentUser"
          placeholder="请输入订单号"
          clearable
        />
      </el-form-item>
      <el-form-item label="年份" prop="startTime">
        <el-date-picker
          v-model="queryParams.startTime"
          type="date"
          placeholder="请选择年份"
          style="width: 180px"
        />
      </el-form-item>
      <el-form-item label="月份" prop="endTime">
        <el-date-picker
          v-model="queryParams.endTime"
          type="date"
          placeholder="请选择月份"
          style="width: 180px"
        />
      </el-form-item>
        
      <el-form-item label="收入" prop="income">
      <el-input
          v-model="queryParams.income"
          placeholder="请输入收入"
          clearable
        />
      </el-form-item>
      <el-form-item label="抽成比例" prop="commissionRate">
      <el-input
          v-model="queryParams.commissionRate"
          placeholder="请输入抽成比例"
          clearable
        />
      </el-form-item>
      <el-form-item label="每月结算时间" prop="settlementTime">
      <el-input
          v-model="queryParams.settlementTime"
          placeholder="请输入每月结算时间"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:role:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:role:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:role:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:role:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="会员昵称" align="center" prop="nickname" />
      <el-table-column label="年份" align="center" prop="startTime" />
      <el-table-column label="月份" align="center" prop="endTime" />
      <el-table-column label="收入" align="center" prop="income" />
      <el-table-column label="抽成比例" align="center" prop="commissionRate" />
      <el-table-column label="每月结算时间" align="center" prop="settlementTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:role:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:role:remove']"
          >删除</el-button>
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-user-solid"
            @click="handleSolid(scope.row)"
            v-hasPermi="['system:role:remove']"
          >拉黑</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-circle-close"
            @click="handleStop(scope.row)"
            v-hasPermi="['system:role:remove']"
          >禁用</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[10, 200, 300, 400]"
      :page-size="10"
      layout="total, sizes, prev, pager, next, jumper"
      align="right"
      :total="6">
    </el-pagination>

    <!-- 添加或修改用户和角色关联对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="会员昵称" prop="nickname">
          <el-input v-model="form.nickname" placeholder="请输入会员昵称" clearable />
        </el-form-item>
        <el-form-item label="年份" prop="startTime">
          <el-date-picker
            v-model="form.startTime"
            type="date"
            placeholder="请选择年份"
            style="width: 180px"
          />
        </el-form-item>
        <el-form-item label="月份" prop="endTime">
          <el-date-picker
            v-model="form.endTime"
            type="date"
            placeholder="请选择月份"
            style="width: 180px"
          />
        </el-form-item>
        <el-form-item label="收入" prop="income">
          <el-input v-model="form.income" placeholder="请输入收入" clearable />
        </el-form-item>
        <el-form-item label="抽成比例" prop="commissionRate">
          <el-input v-model="form.commissionRate" placeholder="请输入抽成比例" clearable />
        </el-form-item>
        <el-form-item label="每月结算时间" prop="settlementTime">
          <el-data-picker
            v-model="form.settlementTime"
            type="datetime"
            placeholder="请选择每月结算时间"
            style="width: 180px"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryParams: {
        nickname: "",
        username: "",
        parentUsername: "",
        status: "",
        isAnchor: ""
      },
      showSearch: true,
      single: false,
      multiple: false,
      loading: false,
      currentPage4: 1,
      roleList: [
        {
          nickname: "会员昵称1",
          username: "年份1",
          parentUsername: "月份1",
          appointmentUser: "订单号1",
          startTime: "2023",
          endTime: "02",
          income: "收入1",
          commissionRate: "抽成比例1",
          settlementTime: "每月结算时间1"
        },
        {
          nickname: "会员昵称2",
          username: "年份2",
          parentUsername: "月份2",
          appointmentUser: "订单号2",
          startTime: "2023",
          endTime: "03",
          income: "收入2",
          commissionRate: "抽成比例2",
          settlementTime: "每月结算时间2"
        },
        {
          nickname: "会员昵称3",
          username: "年份3",
          parentUsername: "月份3",
          appointmentUser: "订单号3",
          startTime: "2023",
          endTime: "04",
          income: "收入3",
          commissionRate: "抽成比例3",
          settlementTime: "每月结算时间3"
        },
        {
          nickname: "会员昵称4",
          username: "年份4",
          parentUsername: "月份4",
          appointmentUser: "订单号4",
          startTime: "2023",
          endTime: "05",
          income: "收入4",
          commissionRate: "抽成比例4",
          settlementTime: "每月结算时间4"
        },
        {
          nickname: "会员昵称5",
          username: "年份5",
          parentUsername: "月份5",
          appointmentUser: "订单号5",
          startTime: "2023",
          endTime: "05",
          income: "收入5",
          commissionRate: "抽成比例5",
          settlementTime: "每月结算时间5"
        },
        {
          nickname: "会员昵称6",
          username: "年份6",
          parentUsername: "月份6",
          appointmentUser: "订单号6",
          startTime: "2023",
          endTime: "05",
          income: "收入6",
          commissionRate: "抽成比例6",
          settlementTime: "每月结算时间6"
        },
      ],
      total: 0,
      title: "",
      open: false,
      form: {},
      rules: {
        nickname: [
          { required: true, message: "请输入会员昵称", trigger: "blur" }
        ],
        username: [
          { required: true, message: "请输入年份", trigger: "blur" }
        ],
        parentUsername: [
          { required: true, message: "请输入月份", trigger: "blur" }
        ],
        appointmentUser: [
          { required: true, message: "请输入订单号", trigger: "blur" }
        ],
        startTime: [          
          { required: true, message: "请选择年份", trigger: "change" }
        ],
        endTime: [
          { required: true, message: "请选择月份", trigger: "change" }
        ],
        status: [
          { required: true, message: "请选择主播状态", trigger: "change" }
        ],
        isAnchor: [
          { required: true, message: "请选择是否主播", trigger: "change" }
        ],
      },
    }
  },
  methods: {
    handleQuery() {},
    resetQuery() {},
    handleExport() {},
    getList() {},
    handleSelectionChange() {},
    cancel() {},
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加主播";
    },
    handleUpdate(row) {
      this.reset();
      this.form = row;
      this.open = true;
      this.title = "修改主播";
    },
    reset() {
      this.form = {
        nickname: "",
        username: "",
        parentUsername: "",
        status: "",
        isAnchor: ""
      }
    },
    handleDelete(row) {
      this.$confirm('此操作将永久删除该主播, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$message({
            type: 'success',
            message: '提交成功!'
          });
          this.open = false;
        } else {
          this.$message({
            type: 'error',
            message: '表单验证失败!'
          });
        }
      })
    },
    handleSolid(row) {
      this.$confirm('此操作将永久拉黑该主播, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '拉黑成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消拉黑'
        });
      });
    },
    handleStop(row) {
      this.$confirm('此操作将永久禁用该主播, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '禁用成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消禁用'
        });
      });
    },
    
  }
}
</script>

<style>

</style>

